document.getElementById('loginForm').addEventListener('submit', function(event) {
    // 获取用户名和密码的值
    var username = document.getElementById('username').value;
    var password = document.getElementById('password').value;

    // 验证用户名和密码是否为空
    if (username === '') {
        document.getElementById('usernameError').textContent = '用户名不能为空';
        event.preventDefault();
        return false;
    } else {
        document.getElementById('usernameError').textContent = '';
    }

    if (password === '') {
        document.getElementById('passwordError').textContent = '密码不能为空';
        event.preventDefault();
        return false;
    } else {
        document.getElementById('passwordError').textContent = '';

        // 将用户名保存在本地存储中
        localStorage.setItem('username', username);

        return true;
    }
});